<template>
	<view class="user clearfix  hv100 ">
		<cu-custom bgColor="bg-white" isBack>
			<block slot="content">粮票转换股票</block>
		</cu-custom>
		<view class="paylines"></view>
		<view class="flex flex-direction bg-white px15 ">
			<view class="py10">粮票转换股票</view>
			<view class="flex align-center justify-between py15">
				<input v-model="money" class="f14" type="number" placeholder="请输入需要转换的粮票数量" />
				<text>粮票</text>
			</view>
			<view class="payline"></view>
			<view class="flex align-center justify-between py15 f12">
				<view class="flex align-center">
					<text>可用粮票</text>
					<text class="mx5"> {{balance}} 粮票，</text>
					<text class="text-red" @click="money=balance">全部</text>
				</view>
				<!-- <text>转换比例 1粮票 ≈ {{radio}} 股票</text> -->
			</view>
			<view class="py10 ">可获得</view>
			<view class="flex align-center justify-between">
				<text class="text-red f26">{{shiMoney}}</text>
				<text>股票</text>
			</view>
			<view class="payline mt15"></view>
			<view class="py10 mt15">支付密码</view>
			<input maxlength="6" v-model="paypwd" class="f14" password placeholder="请输入支付密码" />
			<view class="payline mt15"></view>
		</view>
		
		<view class="red-button discenter" @click="zgp">确认</view>
	</view>
</template>

<script>
import { mapState, mapActions } from 'vuex'
export default {
	data() {
		return {
			money:'',
			radio:1,
			balance:'0.00',
			type:'',
			paypwd:'',
			shouxufei:'0',
			typename:['','粮票','','分红','金种子','拼团余额']
		}
	},
	onLoad(e) {
		this.getData()
	},
	computed:{
		shiMoney(){
			if(this.money==''||this.money==0){
				return '0.00'
			}else{
				return (this.money*this.radio*(1-this.shouxufei*0.01)).toFixed(4)
			}
		}
	},
	methods: {
		async getData() {
			let {
				data:{num,sxfBl,zhBl}
			} = await this.$http.post('wallet.yidougupiaoPage', {}, { tipConfig: { storeBlock: true } })
			this.balance=num
			// this.shouxufei=sxfBl
			this.radio=zhBl
		},
		async zgp() {
			if(this.money==''||this.money==0){
				uni.showToast({
					title:'请输入转换数量',
					icon:"none"
				})
				return false
			}
			if(this.paypwd==''){
				uni.showToast({
					title:'请输入支付密码',
					icon:"none"
				})
				return false
			}
			let params={
				ylbNum:this.money,
				payPassword:this.paypwd,
			}
			let {data} = await this.$http.post('wallet.yidougupiao', params, { tipConfig: { storeLoading: true, isSuccessTip: true, isSuccessBack: true, navigateBack: 1 } })
		},
	}
}
</script>

<style lang="less">
page{
	background-color: #FFFFFF;
}
.payline{
	width: 100%;
	height: 2rpx;
	background-color: #F2F2F2;
}
.paylines{
	width: 100%;
	height: 10rpx;
	background-color: #F2F2F2;
}
.red-button{
	width: calc(100% - 60rpx);
	margin-left: 30rpx;
	height: 90rpx;
	border-radius: 10rpx;
	background-color: #D73329;
	color: #FFFFFF;
	margin-top:80rpx ;
}
</style>
